package hiho.ku._1133;

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int k = in.nextInt();
		if (k < 1 || k > n) {
			System.out.println(-1);
			return;
		}
		int[] a = new int[n + 1];
		for (int i = 1; i <= n; i++)
			a[i] = in.nextInt();
		System.out.println(find(a, 1, n, k));
	}
	
	private static int find(int[] a, int st, int ed, int k) {
		if (st == ed)
			return a[k];
		
		int m = a[(st + ed) / 2];
		int i = st;
		int j = ed;
		while (i <= j) {
			while (a[i] < m)
				i++;
			while (a[j] > m)
				j--;
			if (i <= j) {
				int tmp = a[i];
				a[i] = a[j];
				a[j] = tmp;
				i++;
				j--;
			}
		}
		if (i - j > 1 && k > j && k < i)
			return a[k];
		if (k <= j)
			return find(a, st, j, k);
		else
			return find(a, i, ed, k);
	}

}
